package com.xx.pmis.services.implementations;

import java.util.List;

import com.xx.pmis.model.Medicine;
import com.xx.pmis.persistence.dao.MedicineDAO;
import com.xx.pmis.services.MedicineService;

public class MedicineServiceImpl implements MedicineService {
	MedicineDAO medicineDAO = null;

	public MedicineServiceImpl(MedicineDAO medicineDAO) {
		super();
		this.medicineDAO = medicineDAO;
	}

	public void saveOrUpdateMedicine(Medicine medicine) throws Exception {
		medicineDAO.saveOrUpdate(medicine);
	}

	public void saveMedicine(Medicine medicine) throws Exception {
		medicineDAO.save(medicine);
	}

	public void deleteMedicine(Medicine medicine) throws Exception {
		medicineDAO.delete(medicine);
	}

	public Medicine getMedicineByMedicineID(String medicineID) throws Exception {
		Medicine medicine = medicineDAO.getMedicineByMedicineID(medicineID);
		return medicine;
	}

	public List<Medicine> getAllMedicineByCondition(String hql) throws Exception {
		List<Medicine> medicines = medicineDAO.getAllMedicineByCondition(hql);
		return medicines;
	}

	public List<Medicine> getAllMedicineByConditionByPage(String hql, int currentPage, int lineSize) throws Exception {
		List<Medicine> medicines = medicineDAO.getAllMedicineByConditionByPage(hql, currentPage, lineSize);
		return medicines;
	}

	public int getCountOfMedicineByCondition(String hql) throws Exception {
		return medicineDAO.getAllMedicineByCondition(hql).size();
	}

}
